home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / datescrn.arc / CURSOR.C < prev    next >
Text File  |  1985-12-12  |  3KB  |  175 lines

  1.  
  2. /*---------------------------------------------------------------------
  3. *
  4. *                      C U R S O R
  5. *
  6. *----------------------------------------------------------------------
  7. *
  8. *    Name: curpos
  9. *    Name: cwrite
  10. *    Name: putspec
  11. *    Name: getcurs
  12. *
  13. */
  14.  
  15. #include <stdio.h>
  16.  
  17. struct regval {
  18.     int    ax;
  19.     int    bx;
  20.     int    cx;
  21.     int    dx;
  22.     int    si;
  23.     int    di;
  24.     int    ds;
  25.     int    es;
  26. };
  27.  
  28. static struct regval cursout;
  29.  
  30. /*-
  31. *    Name: curpos                Origin: wrb 04/04/83
  32. *
  33. *    Abstract: Position cursor on IBM PC
  34. *
  35. *    Description:
  36. *
  37. *      Values from 0 - 24 valid for x, 0 - 79 valid for y
  38. */
  39. curpos(row, col)
  40. register short row, col;
  41. {
  42. struct regval curs;
  43.  
  44.     curs.bx = 0;    /* set text page number */
  45.     curs.ax = 2;
  46.     curs.ax <<= 8;    /* set function to set cursor */
  47.     curs.dx = row;
  48.     curs.dx <<= 8;    /* lay in row */
  49.     curs.dx |= col;    /* lay in column */
  50.     sysint(0x10, &curs, &curs);    /* put cursor at position */
  51.  
  52. }
  53.  
  54. /*-
  55. *    Name: cwrite            Origin: wrb 04/04/83
  56. *
  57. *    Abstract: Write specified character cnt # of times
  58. *
  59. *    Description:
  60. *
  61. *        Useful for clearing lines, screen
  62. */
  63. cwrite(ch, cnt)
  64. register short ch, cnt;
  65. {
  66. struct regval curs;
  67.  
  68.     curs.bx = 7;    /* set text page number/attribute */
  69.     curs.ax = 0x900;
  70.     curs.cx = cnt;    /* # characters to write */
  71.     curs.ax |= (char)ch;
  72.     sysint(0x10, &curs, &curs);    /* Write the character(s) */
  73.  
  74. }
  75.  
  76. /*-
  77. *    Name: putspec                Origin: wrb 04/13/83
  78. *
  79. *    Abstract: Output string in modified video
  80. *
  81. *    Description:
  82. *
  83. *      Strings must be NULL terminated.
  84. */
  85. putspec(attrib, s)
  86. register short attrib;
  87. register char *s;
  88. {
  89. short row, col, oldrow, oldcol;
  90. struct regval spccurs;
  91.  
  92.     spccurs.bx = attrib;    /* set text page number/attribute */
  93.     spccurs.cx = 1;        /* # characters to write */
  94.     spccurs.ax = 0x900;
  95.     sysint(0x10, &spccurs, &cursout);
  96.     while(*s) {
  97.         bdos(6,*s++);
  98.         if(*s) sysint(0x10, &spccurs, &cursout);    /* Write the character */
  99.     }
  100. }
  101.  
  102. /*-
  103. *    Name: getcurs            Origin: wrb 
  104. *
  105. *    Abstract: Get current cursor position
  106. *
  107. *    Description:
  108. *
  109. *      Use system interrupt 10 (hex)
  110. */
  111. getcurs(row, col)
  112. register short *row, *col;
  113. {
  114. struct regval getcur;
  115.  
  116.     getcur.ax = 0x300;
  117.     getcur.bx = 0;
  118.     sysint(0x10, &getcur, &getcur);    /* get current cursor pos */
  119.     *row = ((getcur.dx >> 8) & 0xff);
  120.     *col = getcur.dx & 0xff;
  121.  
  122. }
  123.  
  124. /*-
  125. *    Name: scrolldwn                Origin: wrb 04/04/83
  126. *
  127. *    Abstract: Scroll screen down at specified row, col
  128. *
  129. *    Description:
  130. *
  131. *      Scrolls from row, col to line 22.
  132. */
  133. scrolldwn(row, col)
  134. register short row, col;
  135. {
  136. struct regval scr;
  137.  
  138.     scr.ax = 0x0701;    /* Blank one line */
  139.     scr.bx = 0x0700;    /* Attrib for blank line */
  140.     scr.cx = row;
  141.     scr.cx <<= 8;
  142.     scr.cx |= col;
  143.     scr.dx = 22;
  144.     scr.dx <<= 8;    /* lay in row */
  145.     scr.dx |= 79;    /* lay in column */
  146.     sysint(0x10, &scr, &scr);    /* Scroll the screen */
  147.  
  148. }
  149.  
  150. /*-
  151. *    Name: scrollup                Origin: wrb 04/04/83
  152. *
  153. *    Abstract: Scroll screen up at specified row, col
  154. *
  155. *    Description:
  156. *
  157. *      Scrolls from line 22, row 79 to row, col
  158. */
  159. scrollup(row, col)
  160. register short row, col;
  161. {
  162. struct regval scr;
  163.  
  164.     scr.ax = 0x0601;    /* Blank one line */
  165.     scr.bx = 0x0700;    /* Attrib for blank line */
  166.     scr.cx = row;
  167.     scr.cx <<= 8;
  168.     scr.cx |= col;
  169.     scr.dx = 22;
  170.     scr.dx <<= 8;    /* lay in row */
  171.     scr.dx |= 79;    /* lay in column */
  172.     sysint(0x10, &scr, &scr);    /* Scroll the screen */
  173.  
  174. }
  175.